﻿using RayDen.RayEngine.Core;
using RayDen.RayEngine.Core.Devices;
using RayDen.RayEngine.Core.Interface;
using RayDen.RayEngine.Core.Threads;
using RayDen.RayEngine.Managers;
using RayDen.RayEngine.Samplers;

namespace RayDen.RayEngine.Engines.BDPT
{


    public class BDPTPathBuffer : PathBuffer<SBDPTPath>
    {

    }

    public class BDPTDeviceRenderThread : DeviceRenderThread<PathBuffer<SBDPTPath>>
    {
        public BDPTDeviceRenderThread(int index, IIntersectionEngine device, RayEngineScene scn, bool lowLatency, IImageFilm pixelDevice, SamplingContext sc, IFrameManager manager)
            : base(index, device, scn, lowLatency, pixelDevice, sc, manager)
        {
        }
    }

    public class BDPTEngine : BaseRenderingEngine
    {
        public BDPTEngine(RayEngineScene scene) : base(scene)
        {
        }

        public override RenderThread CreateRenderThread(int threadIndex, IntersectionEngine intersectionDevice, RayEngineScene scene, IImageFilm film, IFrameManager frameManager, SamplingContext samplingContext)
        {
            return new BDPTDeviceRenderThread(threadIndex, intersectionDevice, scene, LowLatencySampling, film, samplingContext, frameManager);
        }

        public override ISampler CreateSampler(int width, int height, int maxPathDepth, int threadIndex, int screenStartLine, int windowHeight)
        {
            return SamplerFactory.Instance.CreateSampler(width,
                                                         height,
                                                         maxPathDepth,
                                                         screenStartLine,
                                                         LowLatencySampling,
                                                         threadIndex, windowHeight);
        }

        public override Core.Interface.IImageFilm CreateFilm(int width, int height)
        {
            return new ImageFilm<SBDPTPath>(width, height);
        }
    }
}
